For this creative assignment, I was interested in looking at datasets from Chicago First I loaded relevant r libraries as well as other r libraries that might be useful to me later on and pulled a world map using the libraries loaded below.
library(osmdata)
library(opentripplanner)
library(tidyverse)
library(sf)
library(ggthemes)
library(ggspatial)
library(sp)
library(stringr)
library(rgeos)
library(tidygeocoder)
dcfarmersmarkets<- st_read(
"https://opendata.arcgis.com/datasets/f2e1c2ef9eb44f2899f4a310a80ecec9_2.kml")
## Reading layer `Farmers_Market_Locations' from data source `https://opendata.arcgis.com/datasets/f2e1c2ef9eb44f2899f4a310a80ecec9_2.kml' using driver `KML'
## Simple feature collection with 62 features and 2 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -77.09596 ymin: 38.82899 xmax: -76.91589 ymax: 38.96517
## geographic CRS: WGS 84
NAD83_Virginia_North <- "+proj=lcc +lat_1=39.2 +lat_2=38.03333333333333 +lat_0=37.66666666666666 +lon_0=-78.5 +x_0=3500000 +y_0=2000000 +ellps=GRS80 +units=m +no_defs"
dc_street_features <- opq(bbox = 'Washington DC USA') %>%
add_osm_feature(key = 'highway') %>%
osmdata_sf()
dc_streets <- dc_street_features$osm_lines %>%
st_transform(crs = NAD83_Virginia_North)
ggplot(dc_streets) +
geom_sf() +
theme_map()
path_otp <- otp_dl_jar("OTP")
## The OTP will be saved to OTP/otp.jar
path_data <- file.path(getwd(), "OTP")
path_otp <- paste(path_data, "otp.jar",sep = "/")
otp_build_graph(otp = path_otp, dir = path_data, memory = 1024)
## [1] "21:24:08.753 INFO (OTPServer.java:39) Wiring up and configuring server."
## [2] "21:24:08.757 INFO (GraphBuilder.java:165) Wiring up and configuring graph builder task."
## [3] "21:24:08.759 INFO (GraphBuilder.java:171) Searching for graph builder input files in C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default"
## [4] "21:24:08.759 INFO (OTPMain.java:203) File 'C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default\\build-config.json' is not present. Using default configuration."
## [5] "21:24:08.794 INFO (OTPMain.java:203) File 'C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default\\router-config.json' is not present. Using default configuration."
## [6] "21:24:08.798 INFO (GraphBuilder.java:184) Summarizing GraphBuilderParameters"
## [7] "htmlAnnotations = false"
## [8] "maxHtmlAnnotationsPerFile = 1000"
## [9] "transit = true"
## [10] "useTransfersTxt = false"
## [11] "parentStopLinking = false"
## [12] "stationTransfers = false"
## [13] "stopClusterMode = proximity"
## [14] "subwayAccessTime = 2.0"
## [15] "streets = true"
## [16] "embedRouterConfig = true"
## [17] "areaVisibility = false"
## [18] "platformEntriesLinking = false"
## [19] "matchBusRoutesToStreets = false"
## [20] "fetchElevationUS = false"
## [21] "elevationBucket = null"
## [22] "elevationUnitMultiplier = 1.0"
## [23] "fareServiceFactory = DefaultFareServiceFactory"
## [24] "customNamer = null"
## [25] "wayPropertySet = org.opentripplanner.graph_builder.module.osm.DefaultWayPropertySetSource@3c09711b"
## [26] "staticBikeRental = false"
## [27] "staticParkAndRide = true"
## [28] "staticBikeParkAndRide = false"
## [29] "maxInterlineDistance = 200"
## [30] "pruningThresholdIslandWithoutStops = 40"
## [31] "pruningThresholdIslandWithStops = 5"
## [32] "banDiscouragedWalking = false"
## [33] "banDiscouragedBiking = false"
## [34] "maxTransferDistance = 2000.0"
## [35] "extraEdgesStopPlatformLink = false"
## [36] ""
## [37] "21:24:08.799 INFO (GraphBuilder.java:193) Found OSM file C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default\\dc_streets.osm"
## [38] "21:24:08.815 INFO (OpenStreetMapModule.java:161) Gathering OSM from provider: AnyFileBasedOpenStreetMapProviderImpl(C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default\\dc_streets.osm)"
## [39] "21:24:12.034 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [40] "21:24:12.034 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478727264. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [41] "21:24:12.034 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [42] "21:24:12.034 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727269. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [43] "21:24:12.035 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [44] "21:24:12.035 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478727273. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [45] "21:24:12.035 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [46] "21:24:12.035 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727276. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [47] "21:24:12.035 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [48] "21:24:12.035 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478727279. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [49] "21:24:12.035 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [50] "21:24:12.036 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478727281. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [51] "21:24:12.036 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [52] "21:24:12.036 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478727287. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [53] "21:24:12.036 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [54] "21:24:12.036 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727294. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [55] "21:24:12.036 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [56] "21:24:12.036 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727295. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [57] "21:24:12.037 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [58] "21:24:12.037 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727379. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [59] "21:24:12.037 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1, assumed to be ground-level."
## [60] "21:24:12.037 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1' at 478727381. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [61] "21:24:12.037 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [62] "21:24:12.037 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478732250. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [63] "21:24:12.038 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [64] "21:24:12.038 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478732252. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [65] "21:24:12.075 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [66] "21:24:12.075 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478732263. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [67] "21:24:12.076 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [68] "21:24:12.076 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478732264. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [69] "21:24:12.077 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [70] "21:24:12.078 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 478732265. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [71] "21:24:12.341 WARN (OSMLevel.java:123) Could not determine floor number for layer 6-7, assumed to be ground-level."
## [72] "21:24:12.341 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '6-7' at 615386209. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [73] "21:24:12.341 WARN (OSMLevel.java:123) Could not determine floor number for layer 5-6, assumed to be ground-level."
## [74] "21:24:12.341 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '5-6' at 615386210. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [75] "21:24:12.341 WARN (OSMLevel.java:123) Could not determine floor number for layer 4-5, assumed to be ground-level."
## [76] "21:24:12.342 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '4-5' at 615386211. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [77] "21:24:12.342 WARN (OSMLevel.java:123) Could not determine floor number for layer 3-4, assumed to be ground-level."
## [78] "21:24:12.342 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '3-4' at 615386212. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [79] "21:24:12.342 WARN (OSMLevel.java:123) Could not determine floor number for layer 2-3, assumed to be ground-level."
## [80] "21:24:12.342 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '2-3' at 615386213. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [81] "21:24:12.342 WARN (OSMLevel.java:123) Could not determine floor number for layer 1-2, assumed to be ground-level."
## [82] "21:24:12.342 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '1-2' at 615386214. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [83] "21:24:12.342 WARN (OSMLevel.java:123) Could not determine floor number for layer 0-7, assumed to be ground-level."
## [84] "21:24:12.343 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0-7' at 615386220. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [85] "21:24:12.343 WARN (OSMLevel.java:123) Could not determine floor number for layer 0-7, assumed to be ground-level."
## [86] "21:24:12.343 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0-7' at 615386221. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [87] "21:24:12.343 WARN (OSMLevel.java:123) Could not determine floor number for layer 0-7, assumed to be ground-level."
## [88] "21:24:12.343 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0-7' at 615386222. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [89] "21:24:12.343 WARN (OSMLevel.java:123) Could not determine floor number for layer 0-7, assumed to be ground-level."
## [90] "21:24:12.343 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0-7' at 615386223. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [91] "21:24:12.343 WARN (OSMLevel.java:123) Could not determine floor number for layer 0-1, assumed to be ground-level."
## [92] "21:24:12.343 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0-1' at 615386227. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [93] "21:24:12.487 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [94] "21:24:12.488 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707820430. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [95] "21:24:12.488 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [96] "21:24:12.488 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707820431. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [97] "21:24:12.488 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [98] "21:24:12.488 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707820432. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [99] "21:24:12.488 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [100] "21:24:12.488 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707825087. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [101] "21:24:12.489 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [102] "21:24:12.489 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707825088. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [103] "21:24:12.489 WARN (OSMLevel.java:123) Could not determine floor number for layer 0;1;2;3;4;5;6;7;8;9;10;11;12;13, assumed to be ground-level."
## [104] "21:24:12.489 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '0;1;2;3;4;5;6;7;8;9;10;11;12;13' at 707825089. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [105] "21:24:12.563 WARN (OSMLevel.java:123) Could not determine floor number for layer .5, assumed to be ground-level."
## [106] "21:24:12.563 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '.5' at 769745481. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [107] "21:24:12.563 WARN (OSMLevel.java:123) Could not determine floor number for layer 1.5, assumed to be ground-level."
## [108] "21:24:12.563 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '1.5' at 769745484. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [109] "21:24:12.563 WARN (OSMLevel.java:123) Could not determine floor number for layer 2.5, assumed to be ground-level."
## [110] "21:24:12.564 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '2.5' at 769745486. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [111] "21:24:12.564 WARN (OSMLevel.java:123) Could not determine floor number for layer 3.5, assumed to be ground-level."
## [112] "21:24:12.564 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '3.5' at 769745488. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [113] "21:24:12.568 WARN (OSMLevel.java:123) Could not determine floor number for layer -1;0, assumed to be ground-level."
## [114] "21:24:12.568 WARN (OSMDatabase.java:565) Could not infer floor number for layer called '-1;0' at 771016341. Vertical movement will still be possible, but elevator cost might be incorrect. Consider an OSM level map."
## [115] "21:24:18.605 INFO (OSMDatabase.java:315) Intersecting unconnected areas..."
## [116] "21:24:18.970 INFO (OSMDatabase.java:528) Created 0 virtual intersection nodes."
## [117] "21:24:18.972 INFO (OpenStreetMapModule.java:168) Building street graph from OSM"
## [118] "21:24:37.637 INFO (OpenStreetMapModule.java:393) Skipping visibility graph construction for walkable areas and using just area rings for edges."
## [119] "21:24:42.600 INFO (OpenStreetMapModule.java:424) Done building rings for walkable areas."
## [120] "21:24:42.600 INFO (OpenStreetMapModule.java:431) Building P+R areas"
## [121] "21:24:42.601 INFO (OpenStreetMapModule.java:441) Created 0 P+R."
## [122] "21:24:42.603 INFO (OpenStreetMapModule.java:946) graph-wide: Multiplying all bike safety values by 1.6666666"
## [123] "21:24:43.128 INFO (PruneFloatingIslands.java:60) Pruning isolated islands in street network"
## [124] "21:24:44.104 INFO (StreetUtils.java:103) 1072 sub graphs found"
## [125] "21:24:44.274 WARN (StreetUtils.java:125) Removed edgeless vertices after pruning islands"
## [126] "21:24:44.274 INFO (StreetLinkerModule.java:46) Linking transit stops, bike rental stations, bike parking areas, and park-and-rides to graph . . ."
## [127] "21:24:46.215 INFO (Graph.java:963) Summary (number of each type of annotation):"
## [128] "21:24:46.217 INFO (Graph.java:969) GraphConnectivity - 1053"
## [129] "21:24:46.217 INFO (Graph.java:969) Graphwide - 1"
## [130] "21:24:46.217 INFO (Graph.java:969) LevelAmbiguous - 38"
## [131] "21:24:46.251 INFO (Graph.java:814) Main graph size: |V|=247758 |E|=674222"
## [132] "21:24:46.252 INFO (Graph.java:815) Writing graph C:\\Users\\whytn\\OneDrive\\Documents\\VisCreativeAssignmentOne\\whytnestevens-vis\\OTP\\graphs\\default\\Graph.obj ..."
## [133] "21:24:48.269 INFO (Graph.java:843) Graph written."
## [134] "21:24:48.269 INFO (GraphBuilder.java:153) Graph building took 0.7 minutes."
otp_setup(otp = path_otp, dir = path_data, memory =1024)
## 2020-10-05 21:24:48 OTP is loading and may take a while to be useable
## Router http://localhost:8080/otp/routers/default exists
## 2020-10-05 21:25:49 OTP is ready to use Go to localhost:8080 in your browser to view the OTP
# Connect to opentripplanner
otpcon <- otp_connect()
## Router http://localhost:8080/otp/routers/default exists
iso_5min_walk <-
otp_isochrone(otpcon = otpcon, fromPlace = dcfarmersmarkets,
mode = "WALK", cutoffSec = 300) %>%
st_transform(crs = NAD83_Virginia_North
) %>%
mutate(mode = "walk")
## Warning in otp_isochrone(otpcon = otpcon, fromPlace = dcfarmersmarkets, :
## Failed to get isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-1085047c_174fbbaadd1_-7ff6"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-1085047c_174fbbaadd1_-7fe8"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-1085047c_174fbbaadd1_-7fe7"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-1085047c_174fbbaadd1_-7fe2"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-1085047c_174fbbaadd1_-7fd4"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-1085047c_174fbbaadd1_-7fd3"}]}Failed to get
## isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-1085047c_174fbbaadd1_-7fcd"}]}
iso_5min_drive <-
otp_isochrone(otpcon = otpcon, fromPlace = dcfarmersmarkets,
mode = "CAR", cutoffSec = 300) %>%
st_transform(crs = NAD83_Virginia_North) %>%
mutate(mode = "drive")
## Warning in otp_isochrone(otpcon = otpcon, fromPlace = dcfarmersmarkets, :
## Failed to get isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 300},"id":"fid-1085047c_174fbbaadd1_-7f93"}]}
iso_5min_bike <-
otp_isochrone(otpcon = otpcon, fromPlace = dcfarmersmarkets,
mode = "BICYCLE", cutoffSec = 300) %>%
st_transform(crs = NAD83_Virginia_North) %>%
mutate(mode = "bike")
iso_all_modes <- rbind(iso_5min_drive, iso_5min_walk, iso_5min_bike)
otp_stop()
## [1] "SUCCESS: The process \"java.exe\" with PID 24460 has been terminated."
right_side <- st_bbox(iso_all_modes)$xmax
left_side <- st_bbox(iso_all_modes)$xmin
top_side <- st_bbox(iso_all_modes)$ymax
bottom_side <- st_bbox(iso_all_modes)$ymin
ggplot(iso_all_modes) +
annotation_map_tile(zoomin = 0, type = "stamenbw", progress = "none") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = dcfarmersmarkets) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_viridis_d(name = "Area that is reachable within 5 minutes",
labels = c("By foot", "By bike", "By car")) +
theme_map() +
labs(caption = "Basemap Copyright OpenStreetMap contributors")
## Loading required namespace: raster
iso_areas <- iso_all_modes %>%
mutate(area = st_area(iso_all_modes)) %>%
st_set_geometry(NULL) %>%
pivot_wider(names_from = mode, values_from = area)
ggplot(iso_areas,
aes(x = as.numeric(walk), y = as.numeric(drive))) +
geom_point() +
scale_x_continuous(name =
"Area within a five-minute walking distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(10000, 130000, by = 20000),
labels = breaks / 1000000) +
scale_y_continuous(name =
"Area within a five-minute driving distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(0, 1400000, by = 100000),
labels = breaks / 1000000) +
theme_bw()
## Warning: Removed 8 rows containing missing values (geom_point).
ggplot(iso_areas,
aes(x = as.numeric(walk), y = as.numeric(drive))) +
geom_violin() +
scale_x_continuous(name =
"Area within a five-minute walking distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(10000, 130000, by = 20000),
labels = breaks / 1000000) +
scale_y_continuous(name =
"Area within a five-minute driving distance\nof a farmer's market\n(square km)",
breaks = breaks <- seq(0, 1400000, by = 100000),
labels = breaks / 1000000) +
theme_bw()
## Warning: Removed 8 rows containing non-finite values (stat_ydensity).
ggplot(iso_areas,
aes(x = as.numeric(walk), y = as.numeric(drive))) +
geom_point() +
stat_smooth(color = "black", linetype = 2, size = 0.5) +
scale_x_continuous(name = "Area within a five-minute walking distance\nof a farmer's market\n(square km)") +
scale_y_continuous(name = "Area within a five-minute driving distance\nof a farmer's market\n(square km)") +
theme_solarized()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 8 rows containing non-finite values (stat_smooth).
## Warning: Removed 8 rows containing missing values (geom_point).
addresslist = c("225 7th St SE, Washington, DC",
"1500 20th St NW, Washington, DC",
"901 23rd St NW, Washington, DC",
"1300 Pennsylvania Ave NW, Washington, DC")
points <- geo(address = addresslist, mode = "batch")
head(points)
## # A tibble: 4 x 3
## address lat long
## <chr> <dbl> <dbl>
## 1 225 7th St SE, Washington, DC 38.9 -77.0
## 2 1500 20th St NW, Washington, DC 38.9 -77.0
## 3 901 23rd St NW, Washington, DC 38.9 -77.1
## 4 1300 Pennsylvania Ave NW, Washington, DC 38.9 -77.0
otp_setup(otp = path_otp, dir = path_data, memory =1024)
## 2020-10-05 21:26:17 OTP is loading and may take a while to be useable
## Router http://localhost:8080/otp/routers/default exists
## 2020-10-05 21:27:17 OTP is ready to use Go to localhost:8080 in your browser to view the OTP
# Connect to opentripplanner
otpcon <- otp_connect()
## Router http://localhost:8080/otp/routers/default exists
points <- st_as_sf(x = points,
coords = c("long", "lat"),
crs = 4326)
multiple_points_10min_walk <-
otp_isochrone(otpcon = otpcon, fromPlace = points,
mode = "WALK", cutoffSec = 600)
ggplot(multiple_points_10min_walk) +
annotation_map_tile(zoomin = 0, type = "stamenbw", progress = "none") +
geom_sf(fill ="orange", alpha=0.2) +
theme_map()
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
metrostops <- st_read("https://opendata.arcgis.com/datasets/54018b7f06b943f2af278bbe415df1de_52.kml",
quiet=TRUE)
metrostops2 <- st_read("https://opendata.arcgis.com/datasets/ab5661e1a4d74a338ee51cd9533ac787_50.kml",
quiet=TRUE)
multiple_points_10min_walk <- multiple_points_10min_walk %>%
mutate(transit_score = lengths(st_covers(geometry, metrostops)))
## although coordinates are longitude/latitude, st_covers assumes that they are planar
ggplot(multiple_points_10min_walk) +
annotation_map_tile(zoomin = 0, type = "stamenbw", progress = "none") +
geom_sf(aes(fill=transit_score), alpha=.5) +
theme_map()
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
multiple_points_10min_walk2 <- multiple_points_10min_walk %>%
mutate(transit_score = lengths(st_covers(geometry, metrostops2)))
## although coordinates are longitude/latitude, st_covers assumes that they are planar
ggplot(multiple_points_10min_walk2) +
annotation_map_tile(zoomin = 0, type = "stamenbw", progress = "none") +
geom_sf(aes(fill=transit_score), alpha=.5) +
theme_map()
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
dchoods <- st_read("https://opendata.arcgis.com/datasets/f6c703ebe2534fc3800609a07bad8f5b_17.kml",
quiet = TRUE)
dchoods1 <- as(dchoods, "Spatial")
plot(dchoods1)
points1 <-spsample(dchoods1, n=1000, type='regular')
## Warning in proj4string(obj): CRS object has comment, which is lost in output
plot(points1)
points1 <- st_as_sf(x = points1,
coords = coords,
crs = 4326)
iso_10min_walk1 <-
otp_isochrone(otpcon = otpcon, fromPlace = points1,
mode = "WALK", cutoffSec = 600)
## Warning in otp_isochrone(otpcon = otpcon, fromPlace =
## points1, mode = "WALK", : Failed to get isochrone with error:
## org.opentripplanner.routing.error.VertexNotFoundException: vertices not
## found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone
## with error: org.opentripplanner.routing.error.VertexNotFoundException:
## vertices not found: [from] vertices not found: [from]Failed to
## get isochrone with error: {"type":"FeatureCollection","features":
## [{"type":"Feature","geometry":null,"properties":{"time":
## 600},"id":"fid-2cd904eb_174fbbc0bb4_-7ff5"}]}Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices not
## found: [from] vertices not found: [from]Failed to get isochrone with error:
## org.opentripplanner.routing.error.VertexNotFoundException: vertices not found:
## [from] vertices not found: [from]
otp_stop()
## [1] "SUCCESS: The process \"java.exe\" with PID 37196 has been terminated."
iso_10min_walk1 <- iso_10min_walk1 %>%
mutate(transit_score = lengths(st_covers(geometry, metrostops)))
## although coordinates are longitude/latitude, st_covers assumes that they are planar
out <- data.frame(str_split_fixed(iso_10min_walk1$fromPlace, ",", 2))
out <- st_as_sf(x = out,
coords = c("X2", "X1"),
crs = 4326)
out$transit_score <- iso_10min_walk1$transit_score
ggplot(dchoods) +
geom_sf(fill="NA", color="grey")+
geom_sf(data = out, aes(color=transit_score))+
scale_color_gradientn(name="Number of Metro stops\nwithin a 10 min walk", colors=c("blue", "yellow", "red"))+
theme_map()+
theme(legend.position = c(.7,0),
plot.title = element_text(hjust = 0.5))+
labs(title = "Transit Acessibility Map")
otp_setup(otp = path_otp, dir = path_data, memory =1024)
## 2020-10-05 21:28:21 OTP is loading and may take a while to be useable
## Router http://localhost:8080/otp/routers/default exists
## 2020-10-05 21:29:21 OTP is ready to use Go to localhost:8080 in your browser to view the OTP
# Connect to opentripplanner
otpcon <- otp_connect()
## Router http://localhost:8080/otp/routers/default exists
iso_20min_walk <-
otp_isochrone(otpcon = otpcon, fromPlace = points1,
mode = "WALK", cutoffSec = 1200)
## Warning in otp_isochrone(otpcon = otpcon, fromPlace =
## points1, mode = "WALK", : Failed to get isochrone with error:
## org.opentripplanner.routing.error.VertexNotFoundException: vertices not
## found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices
## not found: [from] vertices not found: [from]Failed to get isochrone with
## error: org.opentripplanner.routing.error.VertexNotFoundException: vertices not
## found: [from] vertices not found: [from]Failed to get isochrone with error:
## org.opentripplanner.routing.error.VertexNotFoundException: vertices not found:
## [from] vertices not found: [from]
otp_stop()
## [1] "SUCCESS: The process \"java.exe\" with PID 16436 has been terminated."
iso_20min_walk <- iso_20min_walk %>%
mutate(transit_score2 = lengths(st_covers(geometry, metrostops)))
## although coordinates are longitude/latitude, st_covers assumes that they are planar
out <- data.frame(str_split_fixed(iso_20min_walk$fromPlace, ",", 2))
out <- st_as_sf(x = out,
coords = c("X2", "X1"),
crs = 4326)
out$transit_score2 <- iso_20min_walk$transit_score2
ggplot(dchoods) +
geom_sf(fill="NA", color="grey")+
geom_sf(data = out, aes(color=transit_score2))+
scale_color_gradientn(name="Number of Metro stops\nwithin a 20 min walk", colors=c("blue", "yellow", "red"))+
theme_map()+
theme(legend.position = c(.7,0),
plot.title = element_text(hjust = 0.5))+
labs(title = "Transit Acessibility Map")
metrobusstops <- st_read("https://opendata.arcgis.com/datasets/54018b7f06b943f2af278bbe415df1de_52.kml",
quiet=TRUE)